package com.chushouya.manager.constants;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.exception.Ex;

import java.util.Objects;

public enum AppLoginRoleEnum implements IEnum<String> {

    user("user", "普通用户"),
    clerk("clerk", "工程师"),
    merchant("merchant", "回收商"),
    store("store", "门店");

    private String value;

    private String name;


    AppLoginRoleEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    @Override
    public String value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.name;
    }

    public static String getName(String value) {
        for (AppLoginRoleEnum thisEnum : AppLoginRoleEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.name;
            }
        }
        return "";
    }

    public static AppLoginRoleEnum get(String value) {
        for (AppLoginRoleEnum thisEnum : AppLoginRoleEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum;
            }
        }
        throw Ex.business("未定义的登录角色");
    }
}
